#from distutils.core import setup
#from distutils.extension import Extension
#from setuptools import setup
#from setuptools.extension import Extension

from numpy.distutils.core import setup
from numpy.distutils.extension import Extension


import sys
from os.path import join

try:
    import numpy
except ImportError:
    print "numpy must be installed to build pywcsgrid."
    print "ABORTING."
    sys.exit(1)

try:
    numpy_include = numpy.get_include()
except AttributeError:
    numpy_include = numpy.get_numpy_include()



from numpy.distutils.misc_util import Configuration

#config = Configuration('pgnumb', "", None)

#config.add_library('pgnumb',
#                   sources=["pgnumb.f"],
#                   )

import glob
tpm_sources = glob.glob("src/tpm/*.c")

def main():
    #dolocal()
    setup(name = "coords",
          version = "0.1b1",
          description = "",
          author = "Jae-Joon Lee",
          maintainer_email = "lee.j.joon@gmail.com",
          license = "???",
          platforms = ["Linux","Mac OS X"], # "Solaris"?
          packages = ['coords'],
          package_dir={'coords':'lib'},


          libraries=[ ["tpm",
                       dict(sources=tpm_sources,
                            include_dirs=['.', 'src/tpm']
                            )],
                      ],


          ext_modules=[ Extension("coords._pytpm",
                                  ["src/_pytpm.pyx",  "src/coord_conv.c",
                                   "src/blackbox.c",
                                   ],
                                  include_dirs=['./src',
                                                numpy_include,
                                                ],
                                  libraries=["tpm"], #, "pgnumb"
                                  ),

                        Extension("coords._pyAstroCoordConvFunc",
                                  ["src/_pyAstroCoordConvFunc.pyx", "src/coord_conv.c",
                                   ],
                                  include_dirs=['./src',
                                                numpy_include,
                                                ],
                                  #extra_objects = ["./_pytpm.so"]
                                  libraries=["tpm"], #, "pgnumb"
                                  ),

                        Extension("coords._pyAstroCoordConv",
                                  ["src/_pyAstroCoordConv.pyx", 
                                   ],
                                  include_dirs=['./src',
                                                numpy_include,
                                                ],
                                  libraries=[], #, "pgnumb"
                                  )                        
                        
                        ],
          )

if __name__ == "__main__":
    main()
